/**
 * author : Kal
 */
package mv.releaser.view;

import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import java.io.File;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Observable;
import java.util.Observer;

import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;

import mv.releaser.controler.ControlerMvReleaser;
import mv.releaser.model.MvReleaser;
import mv.releaser.model.StringUtilities;

import com.jgoodies.forms.factories.*;
import com.jgoodies.forms.layout.*;
import com.toedter.calendar.*;

/*
 * Created by JFormDesigner on Sun Mar 04 11:21:27 GMT 2007
 */

/**
 * @author kal kal
 */
public class MainJPanel extends JPanel implements Observer {

	private ControlerMvReleaser	controler;
	private MvReleaser			mvReleaser;
	private String				releaseName;
	private FileTransferHandler transferHandler;
	public MainJPanel(ControlerMvReleaser controler, MvReleaser mvReleaser) {
		this.controler = controler;
		this.mvReleaser = mvReleaser;
		transferHandler = new FileTransferHandler(this);
		
		initComponents();
		updateDate();

		mvReleaser.addObserver(this);
		setTransferHandler(transferHandler);
	}

	public MainJPanel() {

		initComponents();
		updateDate();
		System.out.println("dans le constructeur de mainjpanel");
	}

	public void openAviFile(File file) {
		controler.openAviFile(file);

	}

	private void browseButtonActionPerformed(ActionEvent e) {
		browse();
	}

	private void artistTextFieldActionPerformed(ActionEvent e) {
		updateReleaseName();
	}

	private void artistTextFieldCaretUpdate(CaretEvent e) {
		updateReleaseName();
	}

	private void languageComboBoxActionPerformed(ActionEvent e) {
		updateReleaseName();
		String current = (String) languageComboBox.getSelectedItem();

		if (current.equals(""))
			return;

		DefaultComboBoxModel model = getLanguageModel();

		for (int i = 0; i < model.getSize(); i++) {
			String element = (String) model.getElementAt(i);
			if (element.equals(current))
				return;
			if (element.toLowerCase().equals(current.toLowerCase())) {
				model.removeElementAt(i);
			}
		}

		model.addElement(current);
	}

	private void generateButtonActionPerformed(ActionEvent e) {
		generate();
	}

	private void previewNfoButtonActionPerformed(ActionEvent e) {
		controler.previewNFO();
	}

	private void crcRefreshButtonActionPerformed(ActionEvent e) {
		controler.crcRefresh();
	}

	protected void generate() {
		controler.generate();

	}

	private void updateDate() {
		dateChooser.setDate(new Date());
	}

	protected void updateReleaseName() {
		// get artist name
		String artist = getArtist();
		// get song title
		String title = getTitleSong();
		// get format
		String format = getFormat();
		// get language
		String lang = getLanguage();
		// get year
		String year = getYear();
		// get group
		String group = getGroup();

		// is HDTV ?
		String hdtv = "";
		if (hdtvCheckBox.isSelected())
			hdtv = "HDTV-";

		// is DVDRIP ?
		String dvdrip = "";
		if (dvdripCheckBox.isSelected())
			dvdrip = "DVDRIP-";

		// is PROPER
		String proper = "";
		if (properCheckBox.isSelected())
			proper = "PROPER-";

		// is REPACK ?
		String repack = "";
		if (repackCheckBox.isSelected())
			repack = "REPACK-";

		// is READNFO ?
		String readnfo = "";
		if (readnfoCheckBox6.isSelected())
			readnfo = "READNFO-";

		// is DIRFIX ?
		String dirfix = "";
		if (dirFixcheckBox.isSelected())
			dirfix = "DIRFIX-";

		// is NFOFIX ?
		String nfofix = "";
		if (nfoFixcheckBox.isSelected())
			nfofix = "NFOFIX-";

		artist = StringUtilities.formatString(artist);
		artist = StringUtilities.capitalize(artist);
		title = StringUtilities.formatString(title);
		title = StringUtilities.capitalize(title);

		releaseName = artist + "-" + title + "-" + hdtv + dvdrip + proper
				+ repack + readnfo + dirfix + nfofix + format + "-";

		if (lang == null || lang.equals(""))
			releaseName += year;
		else
			releaseName += lang + "-" + year;

		if (group != null && !group.equals(""))
			releaseName += "-" + group;

		releaseName = StringUtilities.formatString(releaseName);

		if (artist.equals("") || title.equals(""))
			releaseTextField.setText("");
		else
			releaseTextField.setText(releaseName);

		releaseTextField.setCaretPosition(0);
	}

	protected void browse() {
		controler.openAviFile();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#update(java.util.Observable,
	 *      java.lang.Object)
	 */
	public void update(Observable o, Object arg) {
		// update resolution
		heightTextField.setText("" + mvReleaser.getHeight());
		widthTextField.setText("" + mvReleaser.getWidth());

		// update length
		minutesTextField.setText("" + mvReleaser.getMinutes());
		secondsTextField.setText("" + mvReleaser.getSeconds());

		// update fps
		fpsTextField.setText(mvReleaser.getFPS());

		// update crc
		if (mvReleaser.getCRC() != null)
			crcTextField.setText("" + mvReleaser.getCRC());
		else
			crcTextField.setText("");

		// update file path
		filePathField.setText("" + mvReleaser.getFilePath());
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getArtist()
	 */
	public String getArtist() {
		return artistTextField.getText();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getRelease()
	 */
	public String getRelease() {
		return releaseTextField.getText();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getGenre()
	 */
	public String getGenre() {
		return (String) genreComboBox.getSelectedItem();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getType()
	 */
	public String getType() {
		return (String) typeComboBox.getSelectedItem();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getAudio()
	 */
	public String getAudio() {
		return (String) audioComboBox.getSelectedItem();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getSource()
	 */
	public String getSource() {
		return (String) sourceComboBox.getSelectedItem();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getLanguage()
	 */
	public String getLanguage() {
		return (String) languageComboBox.getSelectedItem();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getDeinterlace()
	 */
	public String getDeinterlace() {
		return (String) deinterlaceComboBox.getSelectedItem();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getCrc()
	 */
	public String getCrc() {
		return crcTextField.getText();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getDate()
	 */
	public Calendar getDate() {
		return dateChooser.getCalendar();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getFormat()
	 */
	public String getFormat() {
		return (String) formatComboBox.getSelectedItem();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getFps()
	 */
	public String getFps() {
		System.out.println("je retourne " + fpsTextField.getText());
		return fpsTextField.getText();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getMinutes()
	 */
	public String getMinutes() {
		return minutesTextField.getText();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getSeconds()
	 */
	public String getSeconds() {
		return secondsTextField.getText();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getWidthResolution()
	 */
	public String getWidthResolution() {
		return widthTextField.getText();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getHeightResolution()
	 */
	public String getHeightResolution() {
		return heightTextField.getText();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.InterfaceMainWindow#getYear()
	 */
	public String getYear() {
		return "" + yearChooser.getYear();
	}

	private void checkBoxItemStateChanged(ItemEvent e) {
		updateReleaseName();
	}

	private void commentsButtonActionPerformed(ActionEvent e) {
		controler.comments();
	}

	private void groupComboBoxActionPerformed(ActionEvent e) {
		updateReleaseName();
		String current = (String) groupComboBox.getSelectedItem();

		if (current.equals(""))
			return;

		DefaultComboBoxModel model = getGroupModel();

		for (int i = 0; i < model.getSize(); i++) {
			String element = (String) model.getElementAt(i);
			if (element.equals(current))
				return;
			if (element.toLowerCase().equals(current.toLowerCase())) {
				model.removeElementAt(i);
			}
		}

		model.addElement(current);
	}

	private void ripperComboBoxActionPerformed(ActionEvent e) {
		String current = (String) ripperComboBox.getSelectedItem();

		if (current.equals(""))
			return;

		DefaultComboBoxModel model = getRipperModel();
		for (int i = 0; i < model.getSize(); i++) {
			String element = (String) model.getElementAt(i);
			if (element.equals(current))
				return;
			if (element.toLowerCase().equals(current.toLowerCase())) {
				model.removeElementAt(i);
			}
		}

		model.addElement(current);
	}

	private void genreComboBoxActionPerformed(ActionEvent e) {
		String current = (String) ripperComboBox.getSelectedItem();

		if (current == null || current.equals(""))
			return;

		DefaultComboBoxModel model = getRipperModel();
		for (int i = 0; i < model.getSize(); i++) {
			String element = (String) model.getElementAt(i);
			if (element.equals(current))
				return;
			if (element.toLowerCase().equals(current.toLowerCase())) {
				model.removeElementAt(i);
			}
		}

		model.addElement(current);
	}

	private void typeComboBoxActionPerformed(ActionEvent e) {
		String current = (String) typeComboBox.getSelectedItem();

		if (current.equals(""))
			return;

		DefaultComboBoxModel model = getTypeModel();
		for (int i = 0; i < model.getSize(); i++) {
			String element = (String) model.getElementAt(i);
			if (element.equals(current))
				return;
			if (element.toLowerCase().equals(current.toLowerCase())) {
				model.removeElementAt(i);
			}
		}

		model.addElement(current);
	}

	private void audioComboBoxActionPerformed(ActionEvent e) {
		String current = (String) audioComboBox.getSelectedItem();

		if (current.equals(""))
			return;

		DefaultComboBoxModel model = getAudioModel();
		for (int i = 0; i < model.getSize(); i++) {
			String element = (String) model.getElementAt(i);
			if (element.equals(current))
				return;
			if (element.toLowerCase().equals(current.toLowerCase())) {
				model.removeElementAt(i);
			}
		}

		model.addElement(current);
	}

	private void sourceComboBoxActionPerformed(ActionEvent e) {
		String current = (String) sourceComboBox.getSelectedItem();

		if (current.equals(""))
			return;

		DefaultComboBoxModel model = getSourceModel();
		for (int i = 0; i < model.getSize(); i++) {
			String element = (String) model.getElementAt(i);
			if (element.equals(current))
				return;
			if (element.toLowerCase().equals(current.toLowerCase())) {
				model.removeElementAt(i);
			}
		}

		model.addElement(current);
	}

	private void deinterlaceComboBoxActionPerformed(ActionEvent e) {
		String current = (String) deinterlaceComboBox.getSelectedItem();

		if (current.equals(""))
			return;

		DefaultComboBoxModel model = getDeinterlaceModel();
		for (int i = 0; i < model.getSize(); i++) {
			String element = (String) model.getElementAt(i);
			if (element.equals(current))
				return;
			if (element.toLowerCase().equals(current.toLowerCase())) {
				model.removeElementAt(i);
			}
		}

		model.addElement(current);
	}

	private void formatComboBoxActionPerformed(ActionEvent e) {
		updateReleaseName();
		// System.out.println("entrée dans formatComboBoxActionPerformed");
		String current = (String) formatComboBox.getSelectedItem();

		if (current.equals(""))
			return;

		DefaultComboBoxModel model = getFormatModel();
		for (int i = 0; i < model.getSize(); i++) {
			String element = (String) model.getElementAt(i);
			if (element.equals(current))
				return;
			if (element.toLowerCase().equals(current.toLowerCase())) {
				// System.out.println("je remove : " + element);
				model.removeElementAt(i);
			}
		}
		// System.out.println("j'ajoute " + current);
		model.addElement(current);
	}

	private void yearChooserPropertyChange(PropertyChangeEvent e) {
		updateReleaseName();
	}

	private void dirFixcheckBoxItemStateChanged(ItemEvent e) {
		updateReleaseName();
	}

	private void nfoFixcheckBoxItemStateChanged(ItemEvent e) {
		updateReleaseName();
	}

	private void initComponents() {
		// JFormDesigner - Component initialization - DO NOT MODIFY
		// //GEN-BEGIN:initComponents
		// Generated using JFormDesigner Evaluation license - kal kal
		contentPanel = new JPanel();
		fileLabel = new JLabel();
		filePathField = new JTextField();
		browseButton = new JButton();
		panel1 = new JPanel();
		artistLabel = new JLabel();
		artistTextField = new JTextField();
		label14 = new JLabel();
		ripperComboBox = new JComboBox();
		label2 = new JLabel();
		titleTextField = new JTextField();
		label19 = new JLabel();
		groupComboBox = new JComboBox();
		label3 = new JLabel();
		releaseTextField = new JTextField();
		panel2 = new JPanel();
		label4 = new JLabel();
		genreComboBox = new JComboBox();
		label9 = new JLabel();
		deinterlaceComboBox = new JComboBox();
		label5 = new JLabel();
		typeComboBox = new JComboBox();
		label10 = new JLabel();
		panel3 = new JPanel();
		crcTextField = new JTextField();
		crcRefreshButton = new JButton();
		label6 = new JLabel();
		audioComboBox = new JComboBox();
		label11 = new JLabel();
		dateChooser = new JDateChooser();
		label7 = new JLabel();
		sourceComboBox = new JComboBox();
		label12 = new JLabel();
		yearChooser = new JYearChooser();
		label8 = new JLabel();
		languageComboBox = new JComboBox();
		panel4 = new JPanel();
		panel6 = new JPanel();
		heightTextField = new JTextField();
		label13 = new JLabel();
		label18 = new JLabel();
		fpsTextField = new JTextField();
		label17 = new JLabel();
		label1 = new JLabel();
		label16 = new JLabel();
		minutesTextField = new JTextField();
		widthTextField = new JTextField();
		secondsTextField = new JTextField();
		label15 = new JLabel();
		formatComboBox = new JComboBox();
		scrollPane1 = new JScrollPane();
		panel7 = new JPanel();
		hdtvCheckBox = new JCheckBox();
		dvdripCheckBox = new JCheckBox();
		properCheckBox = new JCheckBox();
		repackCheckBox = new JCheckBox();
		readnfoCheckBox6 = new JCheckBox();
		dirFixcheckBox = new JCheckBox();
		nfoFixcheckBox = new JCheckBox();
		panel5 = new JPanel();
		commentsButton = new JButton();
		previewNfoButton = new JButton();
		generateButton = new JButton();
		panel8 = new JPanel();
		CellConstraints cc = new CellConstraints();

		//======== this ========
		setBorder(Borders.DIALOG_BORDER);

		// JFormDesigner evaluation mark
//		setBorder(new javax.swing.border.CompoundBorder(
//			new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
//				"JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
//				javax.swing.border.TitledBorder.BOTTOM, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),
//				java.awt.Color.red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener(){public void propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))throw new RuntimeException();}});

		setLayout(new BorderLayout());

		//======== contentPanel ========
		{
			contentPanel.setLayout(new FormLayout(
				new ColumnSpec[] {
					FormFactory.DEFAULT_COLSPEC,
					FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
					new ColumnSpec(ColumnSpec.FILL, Sizes.dluX(150), FormSpec.DEFAULT_GROW),
					FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
					FormFactory.DEFAULT_COLSPEC
				},
				new RowSpec[] {
					new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
					FormFactory.LINE_GAP_ROWSPEC,
					new RowSpec(RowSpec.CENTER, Sizes.PREFERRED, FormSpec.DEFAULT_GROW),
					FormFactory.LINE_GAP_ROWSPEC,
					new RowSpec(RowSpec.CENTER, Sizes.PREFERRED, FormSpec.DEFAULT_GROW),
					FormFactory.LINE_GAP_ROWSPEC,
					FormFactory.PREF_ROWSPEC,
					FormFactory.LINE_GAP_ROWSPEC,
					FormFactory.DEFAULT_ROWSPEC
				}));

			//---- fileLabel ----
			fileLabel.setText("File :");
			contentPanel.add(fileLabel, cc.xy(1, 1));
			contentPanel.add(filePathField, cc.xy(3, 1));

			//---- browseButton ----
			browseButton.setText("Browse ...");
			browseButton.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					browseButtonActionPerformed(e);
				}
			});
			contentPanel.add(browseButton, cc.xy(5, 1));

			//======== panel1 ========
			{
				panel1.setBorder(new TitledBorder("Release Informations"));
				panel1.setLayout(new FormLayout(
					new ColumnSpec[] {
						FormFactory.DEFAULT_COLSPEC,
						FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
						new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
						FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
						FormFactory.DEFAULT_COLSPEC,
						FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
						FormFactory.DEFAULT_COLSPEC
					},
					new RowSpec[] {
						FormFactory.DEFAULT_ROWSPEC,
						FormFactory.LINE_GAP_ROWSPEC,
						FormFactory.DEFAULT_ROWSPEC,
						FormFactory.LINE_GAP_ROWSPEC,
						FormFactory.DEFAULT_ROWSPEC
					}));

				//---- artistLabel ----
				artistLabel.setText("Artist :");
				panel1.add(artistLabel, cc.xywh(1, 1, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

				//---- artistTextField ----
				artistTextField.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						artistTextFieldActionPerformed(e);
					}
				});
				artistTextField.addCaretListener(new CaretListener() {
					public void caretUpdate(CaretEvent e) {
						artistTextFieldCaretUpdate(e);
					}
				});
				panel1.add(artistTextField, cc.xy(3, 1));

				//---- label14 ----
				label14.setText("Ripper :");
				panel1.add(label14, cc.xy(5, 1));

				//---- ripperComboBox ----
				ripperComboBox.setEditable(true);
				ripperComboBox.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						ripperComboBoxActionPerformed(e);
					}
				});
				panel1.add(ripperComboBox, cc.xy(7, 1));

				//---- label2 ----
				label2.setText("Title :");
				panel1.add(label2, cc.xywh(1, 3, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

				//---- titleTextField ----
				titleTextField.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						artistTextFieldActionPerformed(e);
					}
				});
				titleTextField.addCaretListener(new CaretListener() {
					public void caretUpdate(CaretEvent e) {
						artistTextFieldCaretUpdate(e);
					}
				});
				panel1.add(titleTextField, cc.xy(3, 3));

				//---- label19 ----
				label19.setText("Group :");
				panel1.add(label19, cc.xy(5, 3));

				//---- groupComboBox ----
				groupComboBox.setEditable(true);
				groupComboBox.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						groupComboBoxActionPerformed(e);
					}
				});
				panel1.add(groupComboBox, cc.xy(7, 3));

				//---- label3 ----
				label3.setText("Release :");
				panel1.add(label3, cc.xywh(1, 5, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));
				panel1.add(releaseTextField, cc.xywh(3, 5, 1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));
			}
			contentPanel.add(panel1, cc.xywh(1, 3, 5, 1, CellConstraints.FILL, CellConstraints.DEFAULT));

			//======== panel2 ========
			{
				panel2.setBorder(new TitledBorder("Release details"));
				panel2.setLayout(new FormLayout(
					new ColumnSpec[] {
						FormFactory.DEFAULT_COLSPEC,
						FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
						new ColumnSpec(Sizes.dluX(63)),
						FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
						FormFactory.GLUE_COLSPEC,
						FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
						FormFactory.DEFAULT_COLSPEC,
						FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
						FormFactory.PREF_COLSPEC
					},
					new RowSpec[] {
						FormFactory.DEFAULT_ROWSPEC,
						FormFactory.LINE_GAP_ROWSPEC,
						FormFactory.DEFAULT_ROWSPEC,
						FormFactory.LINE_GAP_ROWSPEC,
						FormFactory.DEFAULT_ROWSPEC,
						FormFactory.LINE_GAP_ROWSPEC,
						FormFactory.DEFAULT_ROWSPEC,
						FormFactory.LINE_GAP_ROWSPEC,
						FormFactory.DEFAULT_ROWSPEC
					}));

				//---- label4 ----
				label4.setText("Genre :");
				panel2.add(label4, cc.xywh(1, 1, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

				//---- genreComboBox ----
				genreComboBox.setModel(new DefaultComboBoxModel(new String[] {
					"2step",
					"Acid",
					"Ambient",
					"Beat",
					"Blues",
					"Break",
					"Beat",
					"Classical",
					"Country",
					"Crap",
					"Dance",
					"Disco",
					"Electro",
					"Eurodance",
					"Folk",
					"Freestyle",
					"Happy",
					"Hard",
					"Core",
					"Hard",
					"Core",
					"HardRock",
					"Hip-Hop",
					"House",
					"Indie",
					"Italo",
					"Jazz",
					"Latin",
					"Metal",
					"Other",
					"Pop",
					"Pop-Rock",
					"R&B",
					"Rap",
					"Rock",
					"Soul",
					"Techno",
					"Top",
					"40",
					"Trance",
					"Triphop",
					"Urban",
					"Zouk"
				}));
				genreComboBox.setSelectedIndex(29);
				genreComboBox.setEditable(true);
				genreComboBox.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						genreComboBoxActionPerformed(e);
					}
				});
				panel2.add(genreComboBox, cc.xy(3, 1));

				//---- label9 ----
				label9.setText("Deinterlace :");
				panel2.add(label9, cc.xywh(7, 1, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

				//---- deinterlaceComboBox ----
				deinterlaceComboBox.setEditable(true);
				deinterlaceComboBox.setModel(new DefaultComboBoxModel(new String[] {
					"None",
					"Double",
					"Event",
					"Odd",
					"manual deinterlace 2:2 pulldown",
					"manual deinterlace 3:2 pulldown/iVTC"
				}));
				deinterlaceComboBox.setSelectedIndex(4);
				deinterlaceComboBox.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						deinterlaceComboBoxActionPerformed(e);
					}
				});
				panel2.add(deinterlaceComboBox, cc.xy(9, 1));

				//---- label5 ----
				label5.setText("Type :");
				panel2.add(label5, cc.xywh(1, 3, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

				//---- typeComboBox ----
				typeComboBox.setModel(new DefaultComboBoxModel(new String[] {
					"NTSC",
					"PAL",
					"SECAM"
				}));
				typeComboBox.setSelectedIndex(1);
				typeComboBox.setEditable(true);
				typeComboBox.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						typeComboBoxActionPerformed(e);
					}
				});
				panel2.add(typeComboBox, cc.xy(3, 3));

				//---- label10 ----
				label10.setText("CRC :");
				panel2.add(label10, cc.xywh(7, 3, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

				//======== panel3 ========
				{
					panel3.setLayout(new FormLayout(
						new ColumnSpec[] {
							new ColumnSpec(ColumnSpec.FILL, Sizes.dluX(50), FormSpec.DEFAULT_GROW),
							FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
							FormFactory.DEFAULT_COLSPEC
						},
						RowSpec.decodeSpecs("default")));
					panel3.add(crcTextField, cc.xy(1, 1));

					//---- crcRefreshButton ----
					crcRefreshButton.setIcon(new ImageIcon(getClass().getResource("/mv/releaser/resources/Undo16.gif")));
					crcRefreshButton.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							crcRefreshButtonActionPerformed(e);
						}
					});
					panel3.add(crcRefreshButton, cc.xy(3, 1));
				}
				panel2.add(panel3, cc.xy(9, 3));

				//---- label6 ----
				label6.setText("Audio :");
				panel2.add(label6, cc.xywh(1, 5, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

				//---- audioComboBox ----
				audioComboBox.setModel(new DefaultComboBoxModel(new String[] {
					"CD Audio",
					"TV Audio",
					"DVD Audio"
				}));
				audioComboBox.setEditable(true);
				audioComboBox.setSelectedIndex(1);
				audioComboBox.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						audioComboBoxActionPerformed(e);
					}
				});
				panel2.add(audioComboBox, cc.xy(3, 5));

				//---- label11 ----
				label11.setText("Release Date :");
				panel2.add(label11, cc.xywh(7, 5, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

				//---- dateChooser ----
				dateChooser.setDateFormatString("yyyy/MM/dd");
				panel2.add(dateChooser, cc.xy(9, 5));

				//---- label7 ----
				label7.setText("Source :");
				panel2.add(label7, cc.xywh(1, 7, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

				//---- sourceComboBox ----
				sourceComboBox.setModel(new DefaultComboBoxModel(new String[] {
					"DVB",
					"DVD",
					"HDTV"
				}));
				sourceComboBox.setEditable(true);
				sourceComboBox.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						sourceComboBoxActionPerformed(e);
					}
				});
				panel2.add(sourceComboBox, cc.xy(3, 7));

				//---- label12 ----
				label12.setText("Video Year :");
				panel2.add(label12, cc.xywh(7, 7, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

				//---- yearChooser ----
				yearChooser.addPropertyChangeListener(new PropertyChangeListener() {
					public void propertyChange(PropertyChangeEvent e) {
						yearChooserPropertyChange(e);
					}
				});
				panel2.add(yearChooser, cc.xywh(9, 7, 1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));

				//---- label8 ----
				label8.setText("Language :");
				panel2.add(label8, cc.xywh(1, 9, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

				//---- languageComboBox ----
				languageComboBox.setModel(new DefaultComboBoxModel(new String[] {
					"DE",
					"ES",
					"FR",
					"IT",
					"RU"
				}));
				languageComboBox.setEditable(true);
				languageComboBox.setSelectedIndex(-1);
				languageComboBox.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						languageComboBoxActionPerformed(e);
					}
				});
				panel2.add(languageComboBox, cc.xy(3, 9));
			}
			contentPanel.add(panel2, cc.xywh(1, 5, 5, 1, CellConstraints.FILL, CellConstraints.DEFAULT));

			//======== panel4 ========
			{
				panel4.setLayout(new FormLayout(
					new ColumnSpec[] {
						new ColumnSpec(ColumnSpec.FILL, Sizes.PREFERRED, FormSpec.DEFAULT_GROW),
						FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
						new ColumnSpec(ColumnSpec.FILL, Sizes.dluX(77), FormSpec.DEFAULT_GROW)
					},
					RowSpec.decodeSpecs("fill:76dlu:grow")));

				//======== panel6 ========
				{
					panel6.setBorder(new TitledBorder("Video Details"));
					panel6.setLayout(new FormLayout(
						new ColumnSpec[] {
							FormFactory.DEFAULT_COLSPEC,
							FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
							FormFactory.DEFAULT_COLSPEC,
							FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
							FormFactory.DEFAULT_COLSPEC,
							FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
							new ColumnSpec(Sizes.dluX(22)),
							FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
							FormFactory.DEFAULT_COLSPEC,
							FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
							new ColumnSpec(Sizes.dluX(22))
						},
						new RowSpec[] {
							new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
							FormFactory.LINE_GAP_ROWSPEC,
							new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW)
						}));

					//---- heightTextField ----
					heightTextField.setHorizontalAlignment(SwingConstants.CENTER);
					panel6.add(heightTextField, cc.xy(11, 3));

					//---- label13 ----
					label13.setText("FPS :");
					panel6.add(label13, cc.xywh(1, 3, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

					//---- label18 ----
					label18.setText("x");
					panel6.add(label18, cc.xy(9, 3));

					//---- fpsTextField ----
					fpsTextField.setHorizontalAlignment(SwingConstants.CENTER);
					panel6.add(fpsTextField, cc.xy(3, 3));

					//---- label17 ----
					label17.setText(":");
					panel6.add(label17, cc.xy(9, 1));

					//---- label1 ----
					label1.setText("Format :");
					panel6.add(label1, cc.xywh(1, 1, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

					//---- label16 ----
					label16.setText("Resolution :");
					panel6.add(label16, cc.xywh(5, 3, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

					//---- minutesTextField ----
					minutesTextField.setHorizontalAlignment(SwingConstants.CENTER);
					panel6.add(minutesTextField, cc.xy(7, 1));

					//---- widthTextField ----
					widthTextField.setHorizontalAlignment(SwingConstants.CENTER);
					panel6.add(widthTextField, cc.xy(7, 3));

					//---- secondsTextField ----
					secondsTextField.setHorizontalAlignment(SwingConstants.CENTER);
					panel6.add(secondsTextField, cc.xy(11, 1));

					//---- label15 ----
					label15.setText("Length :");
					panel6.add(label15, cc.xywh(5, 1, 1, 1, CellConstraints.RIGHT, CellConstraints.DEFAULT));

					//---- formatComboBox ----
					formatComboBox.setModel(new DefaultComboBoxModel(new String[] {
						"XviD",
						"DVB Stream",
						"DVDR"
					}));
					formatComboBox.setEditable(true);
					formatComboBox.addActionListener(new ActionListener() {
						public void actionPerformed(ActionEvent e) {
							formatComboBoxActionPerformed(e);
						}
					});
					panel6.add(formatComboBox, cc.xy(3, 1));
				}
				panel4.add(panel6, cc.xywh(1, 1, 1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));

				//======== scrollPane1 ========
				{
					scrollPane1.setBorder(new TitledBorder("Options"));

					//======== panel7 ========
					{
						panel7.setLayout(new FormLayout(
							ColumnSpec.decodeSpecs("pref:grow"),
							new RowSpec[] {
								new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
								FormFactory.LINE_GAP_ROWSPEC,
								new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
								FormFactory.LINE_GAP_ROWSPEC,
								new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
								FormFactory.LINE_GAP_ROWSPEC,
								new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
								FormFactory.LINE_GAP_ROWSPEC,
								new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
								FormFactory.LINE_GAP_ROWSPEC,
								FormFactory.DEFAULT_ROWSPEC,
								FormFactory.LINE_GAP_ROWSPEC,
								FormFactory.DEFAULT_ROWSPEC
							}));

						//---- hdtvCheckBox ----
						hdtvCheckBox.setText("HDTV");
						hdtvCheckBox.addItemListener(new ItemListener() {
							public void itemStateChanged(ItemEvent e) {
								checkBoxItemStateChanged(e);
							}
						});
						panel7.add(hdtvCheckBox, cc.xywh(1, 1, 1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));

						//---- dvdripCheckBox ----
						dvdripCheckBox.setText("DVDRIP");
						dvdripCheckBox.addItemListener(new ItemListener() {
							public void itemStateChanged(ItemEvent e) {
								checkBoxItemStateChanged(e);
							}
						});
						panel7.add(dvdripCheckBox, cc.xywh(1, 3, 1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));

						//---- properCheckBox ----
						properCheckBox.setText("PROPER");
						properCheckBox.addItemListener(new ItemListener() {
							public void itemStateChanged(ItemEvent e) {
								checkBoxItemStateChanged(e);
							}
						});
						panel7.add(properCheckBox, cc.xywh(1, 5, 1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));

						//---- repackCheckBox ----
						repackCheckBox.setText("REPACK");
						repackCheckBox.addItemListener(new ItemListener() {
							public void itemStateChanged(ItemEvent e) {
								checkBoxItemStateChanged(e);
							}
						});
						panel7.add(repackCheckBox, cc.xywh(1, 7, 1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));

						//---- readnfoCheckBox6 ----
						readnfoCheckBox6.setText("READNFO");
						readnfoCheckBox6.addItemListener(new ItemListener() {
							public void itemStateChanged(ItemEvent e) {
								checkBoxItemStateChanged(e);
							}
						});
						panel7.add(readnfoCheckBox6, cc.xywh(1, 9, 1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));

						//---- dirFixcheckBox ----
						dirFixcheckBox.setText("DIRFIX");
						panel7.add(dirFixcheckBox, cc.xy(1, 11));

						//---- nfoFixcheckBox ----
						nfoFixcheckBox.setText("NFOFIX");
						panel7.add(nfoFixcheckBox, cc.xy(1, 13));
					}
					scrollPane1.setViewportView(panel7);
				}
				panel4.add(scrollPane1, cc.xywh(3, 1, 1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));
			}
			contentPanel.add(panel4, cc.xywh(1, 7, 3, 1, CellConstraints.DEFAULT, CellConstraints.TOP));

			//======== panel5 ========
			{
				panel5.setLayout(new FormLayout(
					ColumnSpec.decodeSpecs("default"),
					new RowSpec[] {
						new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
						FormFactory.LINE_GAP_ROWSPEC,
						new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
						FormFactory.LINE_GAP_ROWSPEC,
						new RowSpec(RowSpec.CENTER, Sizes.DEFAULT, FormSpec.DEFAULT_GROW)
					}));

				//---- commentsButton ----
				commentsButton.setText("Comments");
				commentsButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						commentsButtonActionPerformed(e);
					}
				});
				panel5.add(commentsButton, cc.xy(1, 1));

				//---- previewNfoButton ----
				previewNfoButton.setText("Preview NFO");
				previewNfoButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						previewNfoButtonActionPerformed(e);
					}
				});
				panel5.add(previewNfoButton, cc.xy(1, 3));

				//---- generateButton ----
				generateButton.setText("Generate");
				generateButton.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						generateButtonActionPerformed(e);
					}
				});
				panel5.add(generateButton, cc.xy(1, 5));
			}
			contentPanel.add(panel5, cc.xywh(5, 7, 1, 1, CellConstraints.DEFAULT, CellConstraints.FILL));

			//======== panel8 ========
			{
				panel8.setLayout(new FormLayout(
					new ColumnSpec[] {
						new ColumnSpec(ColumnSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
						FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
						FormFactory.DEFAULT_COLSPEC
					},
					RowSpec.decodeSpecs("default")));
			}
			contentPanel.add(panel8, cc.xywh(1, 9, 5, 1));
		}
		add(contentPanel, BorderLayout.CENTER);
		// //GEN-END:initComponents
	}

	// JFormDesigner - Variables declaration - DO NOT MODIFY
	// //GEN-BEGIN:variables
	// Generated using JFormDesigner Evaluation license - kal kal
	private JPanel contentPanel;
	private JLabel fileLabel;
	private JTextField filePathField;
	private JButton browseButton;
	private JPanel panel1;
	private JLabel artistLabel;
	private JTextField artistTextField;
	private JLabel label14;
	private JComboBox ripperComboBox;
	private JLabel label2;
	private JTextField titleTextField;
	private JLabel label19;
	private JComboBox groupComboBox;
	private JLabel label3;
	private JTextField releaseTextField;
	private JPanel panel2;
	private JLabel label4;
	private JComboBox genreComboBox;
	private JLabel label9;
	private JComboBox deinterlaceComboBox;
	private JLabel label5;
	private JComboBox typeComboBox;
	private JLabel label10;
	private JPanel panel3;
	private JTextField crcTextField;
	private JButton crcRefreshButton;
	private JLabel label6;
	private JComboBox audioComboBox;
	private JLabel label11;
	private JDateChooser dateChooser;
	private JLabel label7;
	private JComboBox sourceComboBox;
	private JLabel label12;
	private JYearChooser yearChooser;
	private JLabel label8;
	private JComboBox languageComboBox;
	private JPanel panel4;
	private JPanel panel6;
	private JTextField heightTextField;
	private JLabel label13;
	private JLabel label18;
	private JTextField fpsTextField;
	private JLabel label17;
	private JLabel label1;
	private JLabel label16;
	private JTextField minutesTextField;
	private JTextField widthTextField;
	private JTextField secondsTextField;
	private JLabel label15;
	private JComboBox formatComboBox;
	private JScrollPane scrollPane1;
	private JPanel panel7;
	private JCheckBox hdtvCheckBox;
	private JCheckBox dvdripCheckBox;
	private JCheckBox properCheckBox;
	private JCheckBox repackCheckBox;
	private JCheckBox readnfoCheckBox6;
	private JCheckBox dirFixcheckBox;
	private JCheckBox nfoFixcheckBox;
	private JPanel panel5;
	private JButton commentsButton;
	private JButton previewNfoButton;
	private JButton generateButton;
	private JPanel panel8;
	// JFormDesigner - End of variables declaration //GEN-END:variables

	public String getTitleSong() {
		return titleTextField.getText();
	}

	public String getRipper() {
		return (String) ripperComboBox.getSelectedItem();
	}

	public String getGroup() {
		return (String) groupComboBox.getSelectedItem();
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.test#getGenreModel()
	 */
	public DefaultComboBoxModel getGenreModel() {
		DefaultComboBoxModel model = (DefaultComboBoxModel) genreComboBox
				.getModel();
		return model;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.test#getTypeModel()
	 */
	public DefaultComboBoxModel getTypeModel() {
		DefaultComboBoxModel model = (DefaultComboBoxModel) typeComboBox
				.getModel();
		return model;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.test#getAudioModel()
	 */
	public DefaultComboBoxModel getAudioModel() {
		DefaultComboBoxModel model = (DefaultComboBoxModel) audioComboBox
				.getModel();
		return model;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.test#getSourceModel()
	 */
	public DefaultComboBoxModel getSourceModel() {
		DefaultComboBoxModel model = (DefaultComboBoxModel) sourceComboBox
				.getModel();
		return model;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.test#getLanguageModel()
	 */
	public DefaultComboBoxModel getLanguageModel() {
		DefaultComboBoxModel model = (DefaultComboBoxModel) languageComboBox
				.getModel();
		return model;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.test#getDeinterlaceModel()
	 */
	public DefaultComboBoxModel getDeinterlaceModel() {
		DefaultComboBoxModel model = (DefaultComboBoxModel) deinterlaceComboBox
				.getModel();
		return model;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.test#getFormatModel()
	 */
	public DefaultComboBoxModel getFormatModel() {
		DefaultComboBoxModel model = (DefaultComboBoxModel) formatComboBox
				.getModel();
		return model;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.test#getRipperModel()
	 */
	public DefaultComboBoxModel getRipperModel() {
		DefaultComboBoxModel model = (DefaultComboBoxModel) ripperComboBox
				.getModel();
		for (int i = 0; i < model.getSize(); i++) {
			System.out.println("- " + (String) model.getElementAt(i));
		}
		return model;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see mv.releaser.view.test#getGroupModel()
	 */
	public DefaultComboBoxModel getGroupModel() {
		DefaultComboBoxModel model = (DefaultComboBoxModel) groupComboBox
				.getModel();
		return model;
	}

	public void setAudioModel(DefaultComboBoxModel model) {
		audioComboBox.setModel(model);
	}

	public void setDeinterlaceModel(DefaultComboBoxModel model) {
		deinterlaceComboBox.setModel(model);
	}

	public void setFormatModel(DefaultComboBoxModel model) {
		formatComboBox.setModel(model);
	}

	public void setGenreModel(DefaultComboBoxModel model) {
		genreComboBox.setModel(model);
	}

	public void setGroupModel(DefaultComboBoxModel model) {
		groupComboBox.setModel(model);
	}

	public void setLanguageModel(DefaultComboBoxModel model) {
		languageComboBox.setModel(model);
	}

	public void setRipperModel(DefaultComboBoxModel model) {
		ripperComboBox.setModel(model);
	}

	public void setSourceModel(DefaultComboBoxModel model) {
		sourceComboBox.setModel(model);
	}

	public void setTypeModel(DefaultComboBoxModel model) {
		typeComboBox.setModel(model);
	}

	public boolean isHdtv() {
		return hdtvCheckBox.isSelected();
	}

	public boolean isDvdrip() {
		return dvdripCheckBox.isSelected();
	}

	public boolean isProper() {
		return properCheckBox.isSelected();
	}

	public boolean isRepack() {
		return repackCheckBox.isSelected();
	}

	public boolean isReadNfo() {
		return readnfoCheckBox6.isSelected();
	}

	public boolean isDirFix() {
		return dirFixcheckBox.isSelected();
	}

	public boolean isNfoFix() {
		return nfoFixcheckBox.isSelected();
	}
}
